package com.igeek.health.config;

import com.igeek.health.job.CleanImgJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author fengqq
 * @Description 定时任务的配置
 * @Date 2024/9/10  10:56
 */
@Configuration
public class QuartzConfig {
    @Bean
    public JobDetail jobDetail(){
        return JobBuilder.newJob(CleanImgJob.class).storeDurably().build();
    }

    @Bean
    public Trigger cleamImgTrigger(){
        //0 0 3 * * ?  每天凌晨3点
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0/10 * * * * ?");
        return TriggerBuilder.newTrigger().forJob(jobDetail()).withSchedule(cronScheduleBuilder).build();
    }
}
